var path = require("path");
var express = require("express");
var proxyMiddleware = require("http-proxy-middleware");
var compression = require('compression')
var history = require("connect-history-api-fallback");
var app = express();
app.use(compression());
app.use(
    history({
        // 查看记录
        // verbose: true
    })
);
require("./API/config.js");
var proxyTable = require('./config/proxy')
app.use(express.static(path.join(__dirname, "/dist/")));

Object.keys(proxyTable).forEach(function(context) {
    var options = proxyTable[context];
    if (typeof options === "string") {
        options = {
            target: options
        };
    }
    app.use(proxyMiddleware(context, options));
});

// 
app.listen(5025, function(err) {
    if (err) {
        console.log(err);
        return;
    }
    console.log("server");
});